package com.hkbigdata.source;


import com.hkbigdata.entry.WaterSensor;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * @author liuanbo
 * @creat 2023-03-17-13:02
 * @see 2194550857@qq.com
 */
public class Flink01_Source_Collection {
    public static void main(String[] args) throws Exception {

        List<WaterSensor> waterSensors = Arrays.asList(
                new WaterSensor("ws_001", 1577844001L, 46),
                new WaterSensor("ws_002", 1577844002L, 42),
                new WaterSensor("ws_003", 1577844003L, 43)
        );

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        DataStreamSource<WaterSensor> waterSensorDataStreamSource = env.fromCollection(waterSensors);

        waterSensorDataStreamSource.print();


        env.execute();
    }
}
